#!/usr/bin/env sh
#MAKE BSO
name="bso"

# Root?
[ "$UID" -ne "0" ] && { printf '%b' "NEED ROOT...ABORT\n"; exit 1 ;}
# permission.
[ -e "usr/bin/${name}" ] && chmod +x "usr/bin/${name}"

# copy etc to /
if [ -d "etc" ]; then
   if cp -r "etc" "/"; then
      printf '%b' "etc MOVED...[OK]\n"
   else
      printf '%b' "etc NOT MOVED...[ERROR] ABORT!\n"
      exit 1
   fi
fi

# copy directory usr to /
if [ -d "usr" ]; then
   if cp -r "usr" "/"; then
      printf '%b' "usr MOVED...[OK]\n"
   else
      printf '%b' "usr NOT MOVED...[ERROR] ABORT!\n"
      exit 1
   fi
else
   printf '%b' "DIRECTORY usr NOT FOUND...\n"
   exit 1
fi

#Dir no exist? create.
if [ ! -d "/var/lib/${name}" ]; then
   if ! mkdir "/var/lib/${name}" 1>/dev/null 2>&1; then
      printf '%b' "DIRECTORY /var/lib/${name} NOT CREATED...[ERROR]\n"
      exit 1
   fi
fi




printf '%b' "SUCCESS...\n"
sleep 1s

cat <<EOF

####################### ATENÇÃO/ATTENTION #######################
  GO TO /etc/bso/bso.conf and change VARIABLE:
  DIRECTORY_INSTALL_MODULES="/home/slackjeff"
  FOR YOUR HOME, example:

  DIRECTORY_INSTALL_MODULES="/home/piepie"

EOF
